package com.xiaoshuidi.cloud.module.finance.dal.mysql.finance;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.framework.mybatis.core.mapper.BaseMapperX;
import com.xiaoshuidi.cloud.framework.mybatis.core.util.MyBatisUtils;
import com.xiaoshuidi.cloud.module.finance.controller.admin.finance.vo.account.FinanceAccountWithdrawPageReqVO;
import com.xiaoshuidi.cloud.module.finance.dal.dataobject.finance.FinanceAccountWithdrawDO;
import com.xiaoshuidi.cloud.module.finance.dal.dataobject.finance.FinanceAccountWithdrawExtDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface FinanceAccountWithdrawMapper extends BaseMapperX<FinanceAccountWithdrawDO> {
    default PageResult<FinanceAccountWithdrawExtDO> selectPage(FinanceAccountWithdrawPageReqVO reqVO) {
        IPage<FinanceAccountWithdrawExtDO> mpPage = MyBatisUtils.buildPage(reqVO);
        selectWithdrawPage(reqVO, mpPage);
        return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
    }

    IPage<FinanceAccountWithdrawExtDO> selectWithdrawPage(@Param("example") FinanceAccountWithdrawPageReqVO reqVO, IPage<FinanceAccountWithdrawExtDO> page);

    List<Map<String, Object>> selectConfirmSummary(@Param("reqVo") FinanceAccountWithdrawPageReqVO reqVO);

    @Update("update finance_account_withdraw set apply_member_phone=#{mobile} where apply_member_id=#{oldUserId}")
    void updateApplyMemberUser(@Param("userId")Long userId, @Param("userName")String userName,@Param("mobile") String mobile, @Param("oldUserId")Long oldUserId);

    @Update("update finance_account_withdraw set review_member_phone=#{mobile} where review_member_id=#{oldUserId}")
    void updateReviewMemberUser(@Param("userId")Long userId, @Param("userName")String userName,@Param("mobile") String mobile, @Param("oldUserId")Long oldUserId);
}
